package com.weetop.cfw.base.presenter.imp

import com.weetop.cfw.base.presenter.EnterpriseServicePresenter
import com.weetop.cfw.base.view.BaseView
import com.weetop.cfw.base.view.EnterpriseServiceView
import com.weetop.cfw.bean.SinglePageIntroduceBean
import com.weetop.cfw.callback.RxJavaCallBack
import com.weetop.cfw.home_page.activity.EnterpriseServiceActivity
import com.weetop.cfw.utils.RetrofitUtils
import com.weetop.cfw.utils.RxJavaUtils

class EnterpriseServicePresenterImp(var enterpriseServiceView: EnterpriseServiceView? = null):EnterpriseServicePresenter {

    /**
     * 获取上市服务富文本数据
     */
    override fun getListingServiceData(enterpriseServiceActivity: EnterpriseServiceActivity) {
        enterpriseServiceActivity.showLoadingDialog(enterpriseServiceActivity,"正在获取服务数据...")
        RxJavaUtils.useInAppCompatActivityOnDestory(RetrofitUtils.getApi().getAppRelativeSinglePageIntroduce("appstock"),enterpriseServiceActivity,object:RxJavaCallBack<SinglePageIntroduceBean>(){
            override fun onSuccess(t: SinglePageIntroduceBean?) {
                enterpriseServiceActivity.dismissLoadingDialog()

            }

            override fun onRequestError(t: SinglePageIntroduceBean?) {
                super.onRequestError(t)
                enterpriseServiceActivity.dismissLoadingDialog()
            }

            override fun onErrorResponse(throwable: Throwable?) {
                super.onErrorResponse(throwable)
                enterpriseServiceActivity.dismissLoadingDialog()
            }
        })
    }

    /**
     * 绑定
     */
    override fun attachView(baseView: BaseView) {
        enterpriseServiceView = baseView as? EnterpriseServiceView
    }

    /**
     * 解绑
     */
    override fun detachView() {
        enterpriseServiceView = null
    }
}